package com.xique.door.controller;

import com.xique.common.core.web.controller.BaseController;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.common.security.annotation.PreAuthorize;
import com.xique.door.bean.request.wxMessage.WxMessageTemplateAddRequest;
import com.xique.door.bean.request.wxMessage.WxMessageTemplateEditRequest;
import com.xique.door.bean.request.wxMessage.WxMessageTemplateListRequest;
import com.xique.door.biz.service.IWxMessageTemplateBizService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author shd
 * @create 2022/4/27 13:09
 */
@RestController
@RequestMapping("/wxMessage/template")
public class WxMessageTemplateController extends BaseController {

    @Autowired
    private IWxMessageTemplateBizService wxMessageTemplateBizService;

    @PreAuthorize(hasPermi = "door:wxMessageTemplate:list")
    @GetMapping("/list")
    public AjaxResult list(WxMessageTemplateListRequest request) {
        return wxMessageTemplateBizService.getTemplateList(request);
    }

    @PreAuthorize(hasPermi = "door:wxMessageTemplate:query")
    @GetMapping("/detail")
    public AjaxResult detail(Long id) {
        return wxMessageTemplateBizService.getTemplateDetail(id);
    }

    @PreAuthorize(hasPermi = "door:wxMessageTemplate:add")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody @Valid WxMessageTemplateAddRequest request) {
        return wxMessageTemplateBizService.addTemplate(request);
    }

    @PreAuthorize(hasPermi = "door:wxMessageTemplate:edit")
    @PostMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody @Valid WxMessageTemplateEditRequest request) {
        return wxMessageTemplateBizService.changeStatus(request);
    }
}
